var payId="";
var content_url = window.location.href;
content_url = content_url.split("?");
payId = content_url[ content_url.length-1 ].split("=")[ content_url[ content_url.length-1 ].split("=").length-1 ];
console.log(payId);
$.ajax({
    url:url+"v1/order/detail",
    method:"GET",
    dataType:"json",
    data:{
        orderId:payId
    },
    xhrFields: {
        withCredentials: true // 允许跨域名储存和访问cookie
    }
}).done(function(data){
    console.log(data);
    if(data.code=="success"){
        $(".check div").remove();
        var order=data.data.order;
        console.log(order);
        var create_time=moment(order.create_time).format('YYYY-MM-DD');
        var check_in_time=moment(order.check_in_time).format('YYYY-MM-DD');
        var check_out_time=moment(order.check_out_time).format('YYYY-MM-DD');
        var str="";
        var star_num="";//保存星的数量
        
        for(j=0;j<star_num;j++){
            star_num_str+='<img src="img/icon_star_yes.png">';
        }
        str+=`
        <div class="check_title clearfix">
            <span class="lf">订单状态：`+order.status+`</span>
            <span class="check_title_middle lf">应付金额：¥`+order.amount+`</span>
            <span class="gt">实付金额：¥`+order.amount+`</span>
        </div>
        <div class="check_order">
            <div class="check_order_title">
                订单信息
            </div>
            <div class="check_order_msg">
                <ul>
                    <li><span>订单编号：</span> `+order.orderNo+`</li>
                    <li><span>酒　　店：</span> `+order.hotel.name+`</li>
                    <li><span>房　　型：</span> `+order.roomName+`</li>
                    <li><span>预定时间：</span> `+create_time+`</li>
                    <li><span>入住时间段：</span> `+check_in_time+`至`+check_out_time+`</li>
                </ul>
            </div>
        </div>
        <div class="check_in">
            <div class="check_in_title">
                入住信息
            </div>
            <div class="check_in_msg">
                <p><span>客人姓名：</span>  `+order.customerName+`</p>
                <p><span>手机号码：</span>  `+order.customerPhone+`</p>
            </div>
        </div>
        <div class="my_evaluate">
            <div class="my_evaluate_title">
                我的评价
            </div>
        `;
        if( order.evaluate!=undefined ){
            var star_num_str="";
            star_num=order.evaluate.score;
            //评论图片 
            var evaluate_pic=""
            for(i=0;i<order.evaluate.picture.length;i++){
                evaluate_pic+='<img src="'+url_file+order.evaluate.picture[i]+'">'
            }
            str += `<div class="my_evaluate_msg">
                        <div class="star">`+star_num_str+`</div>
                        <div class="evaluate_content">
                            `+order.evaluate.content+`
                        </div>
                    </div>
                    <div class="my_evaluate_pic">
                        `+evaluate_pic+`
                    </div>
                </div>`
        }else{
            str +=`
                <div class="not_pinglun">还未评论</div></div>
            `
        }
            

            $(".check").append(str);
    }
})